{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This notebook regroups the code sample of the video below, which is a part of the [Hugging Face course](https://huggingface.co/course)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "cellView": "form"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/4IIC2jI9CaU?rel=0&amp;controls=0&amp;showinfo=0\" frameborder=\"0\" allowfullscreen></iframe>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#@title\n",
    "from IPython.display import HTML\n",
    "\n",
    "HTML('<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/4IIC2jI9CaU?rel=0&amp;controls=0&amp;showinfo=0\" frameborder=\"0\" allowfullscreen></iframe>')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Install the Transformers and Datasets libraries to run this notebook."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "! pip install datasets transformers[sentencepiece]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from transformers import AutoTokenizer\n",
    "\n",
    "text = \"This is a text with àccënts and CAPITAL LETTERS\"\n",
    "\n",
    "tokenizer = AutoTokenizer.from_pretrained(\"albert-large-v2\")\n",
    "print(tokenizer.convert_ids_to_tokens(tokenizer.encode(text)))\n",
    "\n",
    "tokenizer = AutoTokenizer.from_pretrained(\"huggingface-course/albert-tokenizer-without-normalizer\")\n",
    "print(tokenizer.convert_ids_to_tokens(tokenizer.encode(text)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "text = \"un père indigné\"\n",
    "\n",
    "tokenizer = AutoTokenizerFast.from_pretrained('distilbert-base-uncased')\n",
    "print(tokenizer.backend_tokenizer.normalizer.normalize_str(text))"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "name": "What is normalization?",
   "provenance": []
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
